package demo2;

import javax.swing.tree.TreeNode;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: liangyuanzhang
 * Date: 2025-4-19
 * Time: 10:39
 */
public class Test {
    //第k层节点的个数
    public int getKlevelNodeCount(TreeNode root,int k){
        if (root == null)
            return 0;
        if (k == 1)
            return 1;
        return getKlevelNodeCount(root.left,k-1) +
                getKlevelNodeCount(root.right,k-1);
    }
}
